package artid.com.arttogo.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.nostra13.universalimageloader.core.ImageLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import artid.com.arttogo.R;
import artid.com.arttogo.bean.CelebritySealInfoParser;
import artid.com.arttogo.bean.InstitutionArtLits;
import artid.com.arttogo.network.BitmapCache;
import artid.com.arttogo.task.CallbackSky;
import artid.com.arttogo.utils.NetUtils;
import artid.com.arttogo.view.DynamicHeightImageView;

public class AuthenticationAdapter extends BaseAdapter {
	private Context mContext;
	private List<InstitutionArtLits> list;

	public AuthenticationAdapter(Context mContext, List<InstitutionArtLits> list) {
		this.mContext = mContext;
		this.list = list;
	}

	public void notifyData(List<InstitutionArtLits> list) {
		// TODO Auto-generated method stub
		this.list = list;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		View v = convertView;
		if (v == null) {
			holder = new ViewHolder();
			v = LayoutInflater.from(mContext).inflate(R.layout.item_authentication, null);
			holder.img=(DynamicHeightImageView) v.findViewById(R.id.itemAuthentication_img);
			holder.describe=(TextView) v.findViewById(R.id.itemAuthentication_describe);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		holder.img.setHeight(list.get(position).getHeight());
		ImageLoader.getInstance().displayImage(list.get(position).getImgurl()
				+ "_"+ (Integer.parseInt(NetUtils.getDisplayMetrics((Activity)mContext).get(NetUtils.DM_WIDTH)) /2) + "x10.png",holder.img);
		holder.describe.setText(list.get(position).getArttitle());
		return v;
	}
	class ViewHolder {
		DynamicHeightImageView img;
		TextView describe;
	}
}
